package _interview100;

import _object.TreeNode;

import java.util.ArrayList;
import java.util.List;

/**
 * 94. 二叉树的中序遍历
 */
public class No94 {
    List<Integer> answer = new ArrayList<>();

    public List<Integer> inorderTraversal(TreeNode root) {
        dfs(root);
        return answer;
    }

    private void dfs(TreeNode node) {
        if (node == null) return;
        dfs(node.left);
        answer.add(node.val);
        dfs(node.right);
    }
}
